//
//  ViewController.m
//  SocketTest
//
//  Created by bianruifeng on 2019/12/27.
//  Copyright © 2019 bianruifeng. All rights reserved.
//

#import "ViewController.h"
#import <SocketIO-Swift.h>
@interface ViewController ()
@property (nonatomic, strong) SocketManager *manager;
@property (nonatomic, strong) SocketIOClient *socket;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
     NSURL* url = [[NSURL alloc] initWithString:@"http://hudie.huazhuangpin168.cn:19967"];
    //    manager = [[SocketManager alloc] initWithSocketURL:url config:@{@"log": @NO, @"forcePolling": @NO,@"doubleEncodeUTF8":@true}];
        self.manager = [[SocketManager alloc] initWithSocketURL:url config:@{@"log": @NO,@"forcePolling":@NO,@"doubleEncodeUTF8":@true}];
        NSArray *cur = @[@{@"username":@"U9633U6625U96ea",
                           @"uid":@"10034",
                           @"token":@"ca97edc050faccdbdbd37ed594a83022",
                           @"roomnum":@"12307",
                           @"stream":@"12307_1577444832"
                           }];
        self.socket = [self.manager defaultSocket];
        
        [self.socket on:@"connect" callback:^(NSArray* data, SocketAckEmitter* ack) {
            [self.socket emit:@"conn" with:cur];
            NSLog(@"socket链接");
        }];
        [self.socket on:@"conn" callback:^(NSArray* data, SocketAckEmitter* ack) {
            NSLog(@"进入房间");
            
        }];
        
        [self.socket on:@"broadcastingListen" callback:^(NSArray* data, SocketAckEmitter* ack) {
            
            NSLog(@"broadcastingListen --------- %@",data);
           
            
        }];
        [self.socket connect];
    
}


@end
